<template>
	<pro-table ref="protable" :loadDataUrl="loadDataUrl" rowKey="id" :columns="columns" :isRowSelection="true" @selectedRowChange="onSelectChange">
		<template slot="approval" slot-scope="{ text, record, index }">
			<a-tag :color="text == 1 ? '#247cf0' : text == 0 ? '#f00' : '#00a095'">{{ text == 0 ? '低于' : text == 1 ? '高于' : '持平' }}</a-tag>
		</template>
	</pro-table>
</template>

<script>
import { rowSelection } from '@/mixins'; //列表页面的一些公用方法
import addUserModal from './module/addUserModal'; //新增或编辑组件
import { api } from '@/api/index.js';
const columns = [
	{
		title: 'openId',
		dataIndex: 'openId',
		key: 'openId'
	},
	{
		title: '学校',
		dataIndex: 'schoolName',
		key: 'schoolName',
		/* 筛选列表 */
		searchInfo: {
			type: 'String', //筛选类型 参考filterbar readme
			value: 'schoolName' //查询字段，如果不配置，怎取key
		}
	},
	{
		title: '专业',
		dataIndex: 'majorName',
		key: 'majorName',
		/* 筛选列表 */
		searchInfo: {
			type: 'select', //筛选类型 参考filterbar readme
			value: 'major', //查询字段，如果不配置，怎取key
			defaultValue: '-1',
			optionlist: [{ value: '-1', text: '全部' }]
		}
	},
	{
		title: '综合得分',
		dataIndex: 'gzScore',
		key: 'gzScore'
	},
	{
		title: '英语得分',
		dataIndex: 'enScore',
		key: 'enScore'
	},
	{
		title: '估分状态',
		dataIndex: 'approval',
		key: 'approval',
		scopedSlots: { customRender: 'approval' }
	}
];
export default {
	name: 'estimatellist',
	mixins: [rowSelection],
	data() {
		return {
			columns: columns,
			filter: {},
			loadDataUrl: api.getRecordList //查询列表接口，请在 api/index.js中配置
		};
	},
	components: { addUserModal },
	filters: {},
	methods: {
		/* 刷新列表当前页 */
		handlerRefresh() {
			this.$refs.protable.handlerRefresh();
		},
		/* 确认是否删除 */
		showDeleteConfirm(keys) {
			let _this = this;
			let title = 'Are you sure you want to delete?';
			this.$confirm({
				title: title,
				content: 'Information cannot be restored after deletion',
				okText: 'OK',
				cancelText: 'Close',
				class: 'confirmbox',
				okType: 'danger',
				onOk() {
					_this.remove(keys);
				},
				onCancel() {}
			});
		},
		/*删除*/
		remove(delId) {
			this.$postAction(api.batchDelUser, {
				userIdList: delId
			}).then(res => {
				if (res.result) {
					this.$message.success('succeed to delete');
					this.handlerRefresh();
				}
			});
		},
		/* 编辑 /添加*/
		editUser(record) {
			this.$refs.addAccountModal.add(record);
		},
		/* 启停用 */
		disableUser(uuid) {
			this.$postAction(api.disableUser + uuid).then(res => {
				if (res.result) {
					this.$message.success('Action successed');
					this.handlerRefresh();
				}
			});
		}
	}
};
</script>

<style></style>
